home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Online / Epic4 / share / epic / help / 6_functions / index < prev    next >
Text File  |  2001-03-21  |  1KB  |  38 lines

  1. Synopsis:
  2.    $index(<characters> <text>)
  3.    $rindex(<characters> <text>)
  4.  
  5. Technical:
  6.    These functions are the equivalent of the BSD library functions index()
  7.    and rindex() (and their ANSI equivalents, strchr() and strrchr()).  They
  8.    return the index to the first character in the given text that appears
  9.    in the list of characters.
  10.  
  11.    The $index() function searches the text left to right, and $rindex()
  12.    searches right to left.  The index, however, always counts from left to
  13.    right, starting at 0 (zero).  The first word passed to the function is
  14.    assumed to be the list of characters to look for; to insert a space, it
  15.    must be escaped with a \, unless it is the first character.  To insert a
  16.    backslash, it must also be escaped.
  17.  
  18. Practical:
  19.    These functions are generally most useful in argument processing.  For
  20.    instance, they can be used to parse a list of command-line switches
  21.    passed to an alias.
  22.  
  23. Returns:
  24.      -1   no matches found
  25.    > -1   index to character
  26.  
  27. Examples:
  28.    $index(abc hello there bob)            returns 12
  29.    $index(xyz hello there bob)            returns -1
  30.    $rindex(abc hello there bob)           returns 14
  31.    $rindex(xyz hello there bob)           returns -1
  32.  
  33. Other Notes:
  34.    Keep in mind that a failed search returns -1, not 0.  This has already
  35.    been stated, but it is misused often enough that this reminder is
  36.    warranted.
  37.  
  38.